//
// Created by 11510 on 2024/6/18.
//

#ifndef DEMO2_COLOR_H
#define DEMO2_COLOR_H
#include <cstring>

class Color {
private:
    char* _RGB;
public:
    char* getRGB()const {
        return _RGB;
    }

    explicit Color(const char* RGB): _RGB(new char[strlen(RGB) + 1]()){
        strcpy(_RGB, RGB);
    }

    Color(const Color& rhs): _RGB(new char[strlen(rhs._RGB) + 1]()){
        strcpy(_RGB, rhs._RGB);
    }

    Color& operator=(const Color& rhs){
        if(&rhs != this){
            delete[] _RGB;
            _RGB = new char[strlen(rhs._RGB) + 1]();
            strcpy(_RGB, rhs._RGB);
        }
        return *this;
    }


    ~Color(){
        if(_RGB != nullptr){
            delete[] _RGB;
            _RGB = nullptr;
        }
    }
};


#endif //DEMO2_COLOR_H
